
import Vue from 'vue'
import Vuex from 'vuex'
// 导入相关的toekn模块
import { setToken, getToken } from '@/utils/storage.js'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // token: JSON.parse(window.localStorage.getItem('token'))
    token: getToken('token')
  },
  mutations: {
    setLoginToken (state, data) {
      state.token = data
      // 把接收到的data对象,保存在本地 调用封装的函数
      setToken('token', data)
      // window.localStorage.setItem('token', JSON.stringify(data))
    }
  },
  actions: {
  },
  modules: {
  }
})
